﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace Blog
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                Controls.Add(new LiteralControl("<h3>"+FormsAuthentication.IsEnabled+"</h3>"));

                if (FormsAuthentication.Authenticate(uiUsername.Text, uiPassword.Text))
                {
                    Controls.Add(new LiteralControl("<h1>Access!!</h1>"));
                    FormsAuthentication.SetAuthCookie(uiUsername.Text, false);
                    //FormsAuthentication.RedirectFromLoginPage(uiUsername.Text, false);
                }
                else
                {
                    //Controls.Clear();
                    Controls.Add(new LiteralControl("<h1>Access Denied</h1>"));
                } 
            }
        }
    }
}